/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.games.epkb.entityClasses;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author plebani
 */
@Entity
@Table(name = "thresholds")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Thresholds.findAll", query = "SELECT t FROM Thresholds t"),
    @NamedQuery(name = "Thresholds.findByIdGPIKPI", query = "SELECT t FROM Thresholds t WHERE t.thresholdsPK.idGPIKPI = :idGPIKPI"),
    @NamedQuery(name = "Thresholds.findByIdComponent", query = "SELECT t FROM Thresholds t WHERE t.thresholdsPK.idComponent = :idComponent"),
    @NamedQuery(name = "Thresholds.findByNormalRangeLow", query = "SELECT t FROM Thresholds t WHERE t.normalRangeLow = :normalRangeLow"),
    @NamedQuery(name = "Thresholds.findByNormalRangeHigh", query = "SELECT t FROM Thresholds t WHERE t.normalRangeHigh = :normalRangeHigh"),
    @NamedQuery(name = "Thresholds.findByEmergencyRangeLow", query = "SELECT t FROM Thresholds t WHERE t.emergencyRangeLow = :emergencyRangeLow"),
    @NamedQuery(name = "Thresholds.findByEmergencyRangeHigh", query = "SELECT t FROM Thresholds t WHERE t.emergencyRangeHigh = :emergencyRangeHigh")})
public class Thresholds implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ThresholdsPK thresholdsPK;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "NormalRangeLow")
    private BigDecimal normalRangeLow;
    @Column(name = "NormalRangeHigh")
    private BigDecimal normalRangeHigh;
    @Column(name = "EmergencyRangeLow")
    private BigDecimal emergencyRangeLow;
    @Column(name = "EmergencyRangeHigh")
    private BigDecimal emergencyRangeHigh;
    @JoinColumn(name = "Id_GPI_KPI", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private GpiKpi gpiKpi;
    @JoinColumn(name = "Id_Component", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Component component;

    public Thresholds() {
    }

    public Thresholds(ThresholdsPK thresholdsPK) {
        this.thresholdsPK = thresholdsPK;
    }

    public Thresholds(String idGPIKPI, String idComponent) {
        this.thresholdsPK = new ThresholdsPK(idGPIKPI, idComponent);
    }

    public ThresholdsPK getThresholdsPK() {
        return thresholdsPK;
    }

    public void setThresholdsPK(ThresholdsPK thresholdsPK) {
        this.thresholdsPK = thresholdsPK;
    }

    public BigDecimal getNormalRangeLow() {
        return normalRangeLow;
    }

    public void setNormalRangeLow(BigDecimal normalRangeLow) {
        this.normalRangeLow = normalRangeLow;
    }

    public BigDecimal getNormalRangeHigh() {
        return normalRangeHigh;
    }

    public void setNormalRangeHigh(BigDecimal normalRangeHigh) {
        this.normalRangeHigh = normalRangeHigh;
    }

    public BigDecimal getEmergencyRangeLow() {
        return emergencyRangeLow;
    }

    public void setEmergencyRangeLow(BigDecimal emergencyRangeLow) {
        this.emergencyRangeLow = emergencyRangeLow;
    }

    public BigDecimal getEmergencyRangeHigh() {
        return emergencyRangeHigh;
    }

    public void setEmergencyRangeHigh(BigDecimal emergencyRangeHigh) {
        this.emergencyRangeHigh = emergencyRangeHigh;
    }

    public GpiKpi getGpiKpi() {
        return gpiKpi;
    }

    public void setGpiKpi(GpiKpi gpiKpi) {
        this.gpiKpi = gpiKpi;
    }

    public Component getComponent() {
        return component;
    }

    public void setComponent(Component component) {
        this.component = component;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (thresholdsPK != null ? thresholdsPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Thresholds)) {
            return false;
        }
        Thresholds other = (Thresholds) object;
        if ((this.thresholdsPK == null && other.thresholdsPK != null) || (this.thresholdsPK != null && !this.thresholdsPK.equals(other.thresholdsPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.games.epkb.entityClasses.Thresholds[ thresholdsPK=" + thresholdsPK + " ]";
    }
    
}
